//引入封装的axios
import request from '../util/request'
import { KEY, API_24H, API_7D, API_CitySearch, API_Now, API_AIR, API_INDICES, API_FORECAST } from './urlAPI'

//未来24小时天气预报请求
//函数表达式
export const fetch7DayData = function (locationID) {
  return request.get(API_7D, {
    params: {
      location: locationID,
      key: KEY,
    }
  })
}

export const fetch24HoutData = function (locationID) {
  return request.get(API_24H, {
    params: {
      location: locationID,
      key: KEY,
    }
  })
}
export const fetchNowDate = function (locationID) {
  return request.get(API_Now, {
    params: {
      location: locationID,
      key: KEY,
    }
  })

}

export const fetchCityDate = function (cityName) {
  return request.get(API_CitySearch, {
    params: {
      location: cityName,
      key: KEY,
    }
  })
}
export const fetchAirDate = function (locationID) {
  return request.get(API_AIR, {
    params: {
      location: locationID,
      key: KEY,
    }
  })

}
export const fetchIndicesDate = function (locationID, type) {
  return request.get(API_INDICES, {
    params: {
      location: locationID,
      type: type,
      key: KEY,
    }
  })

}
export const fetchIndicesDetailDate = function (locationID, type) {
  return request.get(API_FORECAST, {
    params: {
      location: locationID,
      type: type,
      key: KEY,
    }
  })

}
